" vimrc config file
" Description: vim config file
" Maintainer:	LvXin <lvxinxp@126.com>
" Last Change:	2016.12.27
"
set number          " 显示行号
set mouse=a         " 开启鼠标
set autoindent      " 自动对齐
set incsearch       " 搜索查找时动态跟踪
set smartindent
set shiftwidth=4
set softtabstop=4
set expandtab       " 用相应数量的空格代替tab
"set tabstop=2
"set expandtab " In Insert mode: Use the appropriate number of spaces to insert a <Tab>
set cindent
set hlsearch
set laststatus=2                    " 始终显示状态行
set ruler                           " 显示状态行
set encoding=utf-8                  " 内部使用的字符编码
set fileencodings=utf-8,gb2312,gb18030,cp936 " 编辑的文件使用的字符编码
set termencoding=utf-8              " 终端使用的字符编码
set backspace=indent,eol,start      " 定义backspace属性
set virtualedit=all                 " 允许越界移动光标
set path+=**
" set cinoptions=:0,>0                " 修改switch中case的对齐方式(与switch对齐)
set cinoptions=:0                   " 修改switch中case的对齐方式(与switch对齐)
"set path+=./src/include
set background=dark
filetype indent on
syntax enable			    " 允许语法高亮
let mapleader = ","                 " leader映射为逗号“，”
colorscheme myc                     " 默认颜色主题
set cursorline                      " 开启行标记模式

let Tlist_Auto_Open=1
let Tlist_Show_One_File = 1
let Tlist_Exit_OnlyWindow = 1


"----------------------Map my key defined
map <C-w><C-t> :WMToggle<cr>
"map <F2> :buffers<CR>
map <F2> :WMToggle<CR>
map <F3> :TlistToggle<CR>
"map <F4> :run macros/gdb_mappings.vim<CR>
"map <F4> :call SetCursorLineAndColumn()<cr>
map <F12> :!ctags -I __THROW --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p --c++-kinds=+p --fields=+iaS  --extra=+q -R<CR>
map <F11> :!ctags -I __THROW --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p --c++-kinds=+p --fields=+iaS  --extra=+q -R -f ~/.vimtags/systags /usr/include /usr/local/include 

" 开启/关闭当前行列标线
function SetCursorLineAndColumn()
    if !exists("w:CursorStat")
        let w:CursorStat = 0  " 0表示关闭
    endif
    if w:CursorStat==0   "行列全关
        set cursorline
        "set cursorcolumn
        let w:CursorStat=1
    elseif w:CursorStat==1   "行列全开
        "set nocursorcolumn
        "let w:CursorStat=2
    "elseif w:CursorStat==2   "行开列关
        set nocursorline
        set nocursorcolumn
        let w:CursorStat=0
    endif
endfunction

nmap <up> gk
nmap <down> gj
nmap k gk
nmap j gj
nmap <space> :
"vmap <space> :
"nmap <leader><space> :cclose<cr>:wa<cr>:make<cr>:cw<cr>:sleep 2<cr><cr>
nmap <leader><space> :cclose<cr>:wa<cr>:make<cr>:cw<cr><cr>
nmap <leader>i :call SetCursorLineAndColumn()<cr>
nmap <leader>hh <C-w>100h
nmap <leader>w :WMToggle<CR>
nmap <leader>h <C-w>h
nmap <leader>j <C-w>j
nmap <leader>k <C-w>k
nmap <leader>l <C-w>l
nmap <leader>ll <C-w>100l
nmap <leader>H <C-w>H
nmap <leader>J <C-w>J
nmap <leader>K <C-w>K
nmap <leader>L <C-w>L
nmap <leader>= <C-w>=
nmap <leader>_ <C-w>_
nmap <leader>\| <C-w>\|
nmap <leader>. <C-w>10>
nmap <leader>, <C-w>10<
nmap <leader>[ <C-w>5-
nmap <leader>] <C-w>5+
nmap <leader>m :make<CR>
nmap <leader>iip "0p
nmap <leader>z :set foldmethod=indent<cr> "自动折叠

"----------------------About VimGDB
set previewheight=12		" set gdb window initial height
" source key mappings listed in this document
"set asm=0				" don't show any assembly stuff
 "set gdbprg=gdb_invocation		" set GDB invocation string (default 'gdb')

"----------------------About omnicppcomplete
"自动补全相关设置
set nocp
filetype plugin on
"set completeopt=menu,menuone  
let OmniCpp_MayCompleteDot=1    "  打开  . 操作符
let OmniCpp_MayCompleteArrow=1  "打开 -> 操作符
let OmniCpp_MayCompleteScope=1  "打开 :: 操作符
let OmniCpp_NamespaceSearch=1   "打开命名空间
let OmniCpp_GlobalScopeSearch=1  
let OmniCpp_DefaultNamespace=["std"]  
let OmniCpp_ShowPrototypeInAbbr=1  "打开显示函数原型
let OmniCpp_SelectFirstItem = 2 "自动弹出时自动跳至第一个

"autocmd FileType cpp set tags+=~/.vimtags/systags | set shiftwidth=4 | set expandtab
"autocmd FileType cpp set tags+=~/.vim/tags/cpp | set shiftwidth=2 | set expandtab
"autocmd FileType c set tags+=~/.vim/tags/c | set shiftwidth=2 | set expandtab
autocmd FileType asm
            \ set syntax=myasm |
            \ set noexpandtab       " 用相应数量的空格代替tab

autocmd FileType cpp
            \ set tags+=~/.vimtags/systags | 
            \ set shiftwidth=4 |
            \ set expandtab |
            \ set syntax=myc |
            \ colorscheme myc |
            \ set showmatch   
            "\ set foldmethod=indent
autocmd FileType c 
    \ set tags+=~/.vimtags/systags | 
            \ set tags+=~/.vimtags/kerneltags | 
            \ set shiftwidth=4 |
            \ set expandtab |
            \ set syntax=myc |
            \ colorscheme myc |
            \ set showmatch |
            \ set path+=/usr/src/kernels/3.10.0-327.36.2.el7.x86_64/include |
            \ imap <C-l> <C-x><C-o>
            "\ set foldmethod=indent
"showmatch ——括号匹配

autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType python map <F5> :w<CR>:!python %<CR>

autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
"autocmd FileType html set fileencoding=utf-8
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType sql set omnifunc=sqlcomplete#Complete
autocmd FileType php set omnifunc=phpcomplete#CompletePHP | set shiftwidth=4 | set expandtab


"autocmd FileType c set fdm=indent
"

